#!/usr/bin/python
# _*_ coding: utf8 _*_
#Created: 2010. 6. 16.

##GLOBALS
dbFileName = './db/tide.db'

##IMPORTS
import sqlite3
import MoTideDataGetDB
import urllib2

def test():
    #가져올 지역 목록
    dsAreaSet = [\
                    ('BAENGNYEONGDO', u"백령도"),\
                    ('DAECHEONGDO', u"대청도"),\
                    ('SUNWIDO', u"순위도"),\
                    ('DAEYEONPYEONGDO', u"대연평도"),\
                    ('DEOKJEOKDO', u"덕적도"),\
                    ('OEPORI', u"외포리"),\
                    #('GANGHWADO(LARGE BRIGE)', u"강화대교"),\
                    ('INCHEON', u"인천"),\
                    ('ANSAN', u"안산(탄도)"),\
                    ('PYEONGTAEK', u"평택"),\
                    ('DAESAN', u"대산"),\
                    ('ANHEUNG', u"안흥"),\
                    ('BORYEONG', u"보령"),\
                    ('EOCHEONGDO', u"어청도"),\
                    ('WIDO', u"위도"),\
                    ('JANGHANG', u"장항"),\
                    ('GUNSAN_OUTERPORT', u"군산외항"),\
                    ('ANMADO', u"안마도"),\
                    ('YEONGGWANG', u"영광"),\
                    ('MOKPO', u"목포"),\
                    ('DAEHEUKSANDO', u"대흑산도"),\
                    ('SEOGEOCHADO', u"서거차도"),\
                    ('BYEOKPAJIN', u"벽파진"),\
                    ('JINDO', u"진도"),\
                    ('WANDO', u"완도"),\
                    ('CHUJADO', u"추자도"),\
                    ('JEJU', u"제주"),\
                    ('MOSEULPO', u"모슬포"),\
                    ('SEOGWIPO', u"서귀포"),\
                    ('SEONGSANPO', u"성산포"),\
                    ('GEOMUNDO', u"거문도"),\
                    ('NOKDONG', u"녹동"),\
                    ('GOHEUNG', u"고흥(발포)"),\
                    ('GWANGYANG', u"광양"),\
                    ('YEOSU', u"여수"),\
                    ('SAMCHEONPO', u"삼천포"),\
                    ('TONGYEONG', u"통영"),\
                    ('MASAN', u"마산"),\
                    ('JINHAE', u"진해"),\
                    ('GEOJEDO', u"거제도(구조라)"),\
                    ('GADEOKDO', u"가덕도"),\
                    ('BUSAN', u"부산"),\
                    ('ULSAN', u"울산"),\
                    ('POHANG', u"포항"),\
                    ('HUPO', u"후포"),\
                    ('MUKHO', u"묵호"),\
                    ('SOKCHO', u"속초"),\
                    ('WONSAN', u"원산"),\
                    ('ULLEUNGDO', u"울릉도"),\
                    ('IEODO', u"이어도")
                ]
    #모든 지역 리스트에 대하여 데이터 수집
    for stArea in dsAreaSet:
        stAreaURL, stAreaName =  stArea
        a = MoTideDataGetDB.CTideDataGetDB(stAreaURL, 2010, 6, 22)
        print stAreaName + "\r"
        a.GetDataFormed()
        print "\r\r"

    return
   

def main():
    pass
    #con = sqlite3.connect(dbFileName)
    #cur = con.cursor()
    #cur.execute("CREATE TABLE IF NOT EXISTS BORYEONG(Month Integer, Day Integer ,Hour Integer, Min Integer, Height Integer); ")
    #con.commit()
   
    #a = MoTideDataGetDB.CTideDataGetDB('INCHEON', 2010, 5, 10)
    #a.GetDataFormed()
    
    #opener = urllib2.build_opener()
    #opener.addheaders = [('User-agent', 'Mozilla/5.0')]
    #response = opener.open('http://www.khoa.go.kr/info/tide/YEONGGWANG/201006.htm')
    #print type(response.read().decode('cp949'))
    
    test()

    

if __name__ == "__main__":
    main()
